package com.mf.ergate.controller.bo.pt;

import com.mf.ergate.api.bo.pt.PtOrderDeliveryFeeDetailRemoteService;
import com.mf.ergate.api.bo.pt.model.dto.PtOrderDeliveryFeeDetailCreateDto;
import com.mf.ergate.api.bo.pt.model.dto.PtOrderDeliveryFeeDetailDeleteDto;
import com.mf.ergate.api.bo.pt.model.dto.PtOrderDeliveryFeeDetailQueryDto;
import com.mf.ergate.api.bo.pt.model.dto.PtOrderDeliveryFeeDetailUpdateDto;
import com.mf.ergate.api.bo.pt.model.vo.PtOrderDeliveryFeeDetailVo;
import com.mf.ergate.common.utils.MfBeanUtils;
import com.mf.ergate.domain.model.bo.pt.PtOrderDeliveryFeeDetailEntity;
import com.mf.ergate.service.bo.pt.PtOrderDeliveryFeeDetailService;
import com.mf.framework.common.model.Page;
import com.mf.framework.common.model.RemotePage;
import com.mf.framework.common.model.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 跑腿订单配送费用明细Controller
 * User: zhaoming
 * DateTime: 2019-01-28
 * To change this template use File | Settings | File Templates.
 */
@RestController
public class PtOrderDeliveryFeeDetailController implements PtOrderDeliveryFeeDetailRemoteService {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private PtOrderDeliveryFeeDetailService ptOrderDeliveryFeeDetailService;

    /**
     * 新增
     * @param ptOrderDeliveryFeeDetailCreateDto 跑腿订单配送费用明细新增Dto
     * @return 跑腿订单配送费用明细
     */
    public Result<PtOrderDeliveryFeeDetailVo> insert(@RequestBody PtOrderDeliveryFeeDetailCreateDto ptOrderDeliveryFeeDetailCreateDto) {
        PtOrderDeliveryFeeDetailEntity ptOrderDeliveryFeeDetailEntity = MfBeanUtils.copyObject(ptOrderDeliveryFeeDetailCreateDto, PtOrderDeliveryFeeDetailEntity.class);
        ptOrderDeliveryFeeDetailEntity = ptOrderDeliveryFeeDetailService.insert(ptOrderDeliveryFeeDetailEntity);
        PtOrderDeliveryFeeDetailVo ptOrderDeliveryFeeDetailVo = MfBeanUtils.copyObject(ptOrderDeliveryFeeDetailEntity, PtOrderDeliveryFeeDetailVo.class);
        return new Result<>(ptOrderDeliveryFeeDetailVo);
    }

    /**
     * 根据唯一编号更新
     * @param ptOrderDeliveryFeeDetailUpdateDto 跑腿订单配送费用明细更新Dto
     * @return 执行结果
     */
    public Result<Boolean> updateByUniqueNo(@RequestBody PtOrderDeliveryFeeDetailUpdateDto ptOrderDeliveryFeeDetailUpdateDto) {
        PtOrderDeliveryFeeDetailEntity ptOrderDeliveryFeeDetailEntity = MfBeanUtils.copyObject(ptOrderDeliveryFeeDetailUpdateDto, PtOrderDeliveryFeeDetailEntity.class);
        Boolean flag = ptOrderDeliveryFeeDetailService.updateByUniqueNo(ptOrderDeliveryFeeDetailEntity);
        return new Result<>(flag);
    }

    /**
     * 根据唯一编号删除(逻辑删除)
     * @param ptOrderDeliveryFeeDetailDeleteDto 跑腿订单配送费用明细删除Dto
     * @return 结果集
     */
    public Result<Boolean> deleteByUniqueNo(@RequestBody PtOrderDeliveryFeeDetailDeleteDto ptOrderDeliveryFeeDetailDeleteDto){
        PtOrderDeliveryFeeDetailEntity ptOrderDeliveryFeeDetailEntity = MfBeanUtils.copyObject(ptOrderDeliveryFeeDetailDeleteDto, PtOrderDeliveryFeeDetailEntity.class);
        Boolean flag = ptOrderDeliveryFeeDetailService.deleteByUniqueNo(ptOrderDeliveryFeeDetailEntity);
        return new Result<>(flag);
    }

    /**
     * 根据唯一编号查询
     * @param uniqueNo 唯一编号
     * @return 跑腿订单配送费用明细
     */
    public Result<PtOrderDeliveryFeeDetailVo> selectByUniqueNo(@RequestBody String uniqueNo) {
        PtOrderDeliveryFeeDetailEntity ptOrderDeliveryFeeDetailEntity = ptOrderDeliveryFeeDetailService.selectByUniqueNo(uniqueNo);
        PtOrderDeliveryFeeDetailVo ptOrderDeliveryFeeDetailVo = MfBeanUtils.copyObject(ptOrderDeliveryFeeDetailEntity, PtOrderDeliveryFeeDetailVo.class);
        return new Result<>(ptOrderDeliveryFeeDetailVo);
    }

    /**
     * 根据条件查询
     * @param ptOrderDeliveryFeeDetailQueryDto 跑腿订单配送费用明细查询Dto
     * @return 跑腿订单配送费用明细列表
     */
    public Result<List<PtOrderDeliveryFeeDetailVo>> selectByCondition(@RequestBody PtOrderDeliveryFeeDetailQueryDto ptOrderDeliveryFeeDetailQueryDto) {
        List<PtOrderDeliveryFeeDetailEntity> ptOrderDeliveryFeeDetailEntities = ptOrderDeliveryFeeDetailService.selectByCondition(ptOrderDeliveryFeeDetailQueryDto);
        List<PtOrderDeliveryFeeDetailVo> ptOrderDeliveryFeeDetailVos = MfBeanUtils.copyList(ptOrderDeliveryFeeDetailEntities, PtOrderDeliveryFeeDetailVo.class);
        return new Result<>(ptOrderDeliveryFeeDetailVos);
    }

    /**
     * 根据条件查询数量
     * @param ptOrderDeliveryFeeDetailQueryDto 跑腿订单配送费用明细查询Dto
     * @return 数量
     */
    public Result<Integer> selectCount(@RequestBody PtOrderDeliveryFeeDetailQueryDto ptOrderDeliveryFeeDetailQueryDto) {
        return new Result<>(ptOrderDeliveryFeeDetailService.selectCount(ptOrderDeliveryFeeDetailQueryDto));
    }

    /**
     * 根据条件分页查询
     * @param remotePage 远程分页对象
     * @return 跑腿订单配送费用明细分页列表
     */
    public Result<Page<PtOrderDeliveryFeeDetailVo>> selectPage(@RequestBody RemotePage<PtOrderDeliveryFeeDetailQueryDto> remotePage){
        Page<PtOrderDeliveryFeeDetailEntity> ptOrderDeliveryFeeDetailEntityPage = ptOrderDeliveryFeeDetailService.selectPage(remotePage.getPage(), remotePage.getObj());
        Page<PtOrderDeliveryFeeDetailVo> page = MfBeanUtils.copyPage(ptOrderDeliveryFeeDetailEntityPage, PtOrderDeliveryFeeDetailVo.class);
        return new Result<>(page);
    }

}